Brushless 15 Click
Brushless 15 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Oct 2021.
- Type : PWM type
Software Support
Example Description
This example demonstrates the use of the Brushless 15 Click board by driving the motor in both directions at different speeds.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Brushless15
Example Key Functions
- brushless15_cfg_setup Config Object Initialization function.
void brushless15_cfg_setup(brushless15_cfg_t *cfg)
Brushless 15 configuration object setup function.
Brushless 15 Click configuration object.
Definition brushless15.h:138
- brushless15_init Initialization function.
err_t brushless15_init(brushless15_t *ctx, brushless15_cfg_t *cfg)
Brushless 15 initialization function.
Brushless 15 Click driver selector.
Definition brushless15.h:117
- brushless15_default_cfg Click Default Configuration function.
err_t brushless15_default_cfg(brushless15_t *ctx)
Brushless 15 default configuration function.
- brushless15_set_duty_cycle This function sets the PWM duty cycle in percentages ( Range[ 0..1 ] ).
err_t brushless15_set_duty_cycle(brushless15_t *ctx, float duty_cycle)
Brushless 15 sets PWM duty cycle.
- brushless15_enable_device This function enables the device by setting the EN pin to low logic state.
void brushless15_enable_device(brushless15_t *ctx)
Brushless 15 enable device function.
- brushless15_switch_direction This function switches the direction by toggling the DIR pin state.
void brushless15_switch_direction(brushless15_t *ctx)
Brushless 15 switch direction function.
Application Init
Initializes the driver and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ BRUSHLESS15_ERROR
Definition brushless15.h:159
#define BRUSHLESS15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition brushless15.h:98
void application_init(void)
Definition main.c:36
Application Task
Controls the motor speed by changing the PWM duty cycle once per second. The duty cycle ranges from 20% to 80%. At the minimal speed, the motor switches direction. Each step will be logged on the USB UART where you can track the program flow.
{
static int8_t duty_cnt = 2;
static int8_t duty_inc = 1;
float duty = duty_cnt / 10.0;
log_printf( &logger, "> Duty: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
Delay_ms ( 1000 );
duty_cnt += duty_inc;
if ( 8 == duty_cnt )
{
duty_inc = -1;
}
else if ( 1 == duty_cnt )
{
duty_inc = 1;
duty_cnt = 2;
log_printf( &logger, " Switch direction\r\n\n" );
}
}
void application_task(void)
Definition main.c:71
Note
The maximal PWM Clock frequency for this Click board is 1 kHz. So, depending on the selected setup the user will need to lower the MCU's main clock frequency in the setup in order to get the PWM clock frequency down to 1 kHz.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.